<template>
	<div class="page">
		<!-- 商品列表 -->
		<div class="global-list">

			<div class="global-item" @click='handleClick(item)' v-for="(item,index) in goodsUnitList" :key="index">
				<!-- 商品信息 -->
				<div class="flex goods-item">
					<div class="wes-2 goods-name">{{item.name}}</div>
				</div>
			</div>
		</div>
	</div>
</template>

<script>
	import {
		getGoodsUnitList
	} from "@/api/goods";
	export default {

		data() {
			return {

				searchForm: {
					// 搜索框初始化对象
					pageNumber: 1, // 当前页数
					pageSize: 10, // 页面大小
					sort: "create_time", // 默认排序字段
					order: "desc", // 默认排序方式
					sn: "", //商品编号
					categoryPath: ''
				},
				goodsUnitList: []


			};
		},
		onShow() {
			this.load();
		},
		//   触底
		onReachBottom() {
			this.searchForm.pageNumber++;
			this.init();
		},
		methods: {
			load() {
				this.searchForm.pageNumber = 1;
				this.goodsUnitList = [];
				this.init();
			},
			handleClick(val) {
				
				uni.$emit('goodsUnit',val)
				uni.navigateBack()
			},
			async init() {
				uni.showLoading({
					title: '加载中'
				})
				getGoodsUnitList(this.unitParams).then((res) => {
					if (res.data.success) {
						this.goodsUnitList.push(...res.data.result.records);
					}
					uni.hideLoading()
				});

			},
		},
	};
</script>

<style lang="scss" scoped>
	@import "@/components/global.scss";
</style>
